//
//  CLconcreteTableCell.m
//  I-want-go
//
//  Created by dllo on 15/10/26.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "CLconcreteTableCell.h"
#import "CLgoodsCollectionCell.h"
#import "CLpic.h"
#import "CLtool.h"
#import "CLscreen.h"
@interface CLconcreteTableCell ()<UICollectionViewDataSource, UICollectionViewDelegate>

@property(nonatomic, retain)NSMutableArray *consArr;
@end



@implementation CLconcreteTableCell

- (void)dealloc {
    [_consArr release];
    [_consCollectionView release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)createView {
    
    UICollectionViewFlowLayout *flowt = [[UICollectionViewFlowLayout alloc] init];
    flowt.itemSize = CGSizeMake(72 * SWIDTH, 95 * SHEIGHT);
    
    self.consCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 375 * SWIDTH, 340 * SHEIGHT) collectionViewLayout:flowt];
    self.consCollectionView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.consCollectionView];
    [self.consCollectionView registerClass:[CLgoodsCollectionCell class] forCellWithReuseIdentifier:@"rel"];
    [_consCollectionView release];
    
    flowt.sectionInset = UIEdgeInsetsMake(20 * SHEIGHT, 5 * SWIDTH, 2 * SWIDTH, 2 * SHEIGHT);
    
    self.consCollectionView.dataSource = self;
    self.consCollectionView.delegate = self;
    
    
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.pictArr.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    CLgoodsCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"rel" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    
//    NSLog(@"%@", self.pictArr);
    CLpic *ppp = self.pictArr[indexPath.row];
    cell.myLabel.text = ppp.name;
    [cell.picImage sd_setImageWithURL:[NSURL URLWithString:ppp.logo]];
    
    return cell;
}


- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    CLpic *ppp = self.pictArr[indexPath.row];
    [self.Delat pushNext:ppp.mid Withtitle:ppp.name];
        
}








- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
